#include "../source/server.hpp"

void OnConnected(const PtrConnection& conn)
{
    LOG_DBG("New Connection:%p", conn.get());
}
void OnClosed(const PtrConnection& conn)
{
    LOG_DBG("Closed Connection:%p", conn.get());
}
void OnMessage(const PtrConnection& conn, Buffer* buf)
{
    LOG_DBG("%s", buf->ReadPostion());
    buf->MoveReadOffset(buf->ReadableDataSize());
    std::string str = "我是吕培";
    conn->Send(str.c_str(), str.size());
    conn->Shutdown();  
}
int main()
{
    TcpServer server(8500);
    server.SetThreadCount(2);
    server.EnableInactiveRelease(10);
    server.SetClosedCallback(OnClosed);
    server.SetConnectedCallback(OnConnected);
    server.SetMessageCallback(OnMessage);
    server.Start();
    return 0;
}